﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

using Membership.Library;
using Membership.Library.Web; 
using Membership.UI.UtilityCommon;

namespace Membership.UI.PersonnelManagement
{
    public partial class EmployeeEdit : Page
    {
        MembershipDomainContext _context = new MembershipDomainContext();
        public EmployeeEdit()
        {
            InitializeComponent();
            CustomInitializeComponent();
        }
        public Employee OpEmp { get; set; }
        public void CustomInitializeComponent()
        {
            NationComboBox.Items.Clear();

            NationComboBox.Items.Add(new ItemObject() { Text = "汉族", Nation = "hanzu" });
            NationComboBox.Items.Add(new ItemObject() { Text = "壮族", Nation = "zhuangzu" });

            NationComboBox.DisplayMemberPath = "Text";


        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {

            //Employee record1 = new Employee()
            //{
            //    EmployeeId = Guid.NewGuid().ToString(),
            //    EmployeeName = EmployeeNameTextBox.Text,
            //    Nation = (NationComboBox.SelectedItem as ItemObject).Text,
            //    Birthday = Convert.ToDateTime(BirthdayDatePicker.Text)

            //};
            OpEmp.EmployeeId = Guid.NewGuid().ToString();
            OpEmp.Nation = (NationComboBox.SelectedItem as ItemObject).Text;
            _context.Employees.Add(OpEmp);
            _context.SubmitChanges();

            NavigationService.Navigate(new Uri("/PersonnelManagement/EmployeeList.xaml", UriKind.Relative));
        }

    }
}
